<%@ page pageEncoding="UTF-8"%>
<%@ page import="java.util.*"%>
<%@ page import="com.hwhp.entity.*"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>角色管理</title>
		<LINK href="<%=basePath%>css/milkwhite.css" type=TEXT/CSS
			rel=StyleSheet></LINK>
		<LINK href="<%=basePath%>css/htmilkwhite.css" type=TEXT/CSS
			rel=StyleSheet></LINK>
		<LINK href="<%=basePath%>css/dhtmlxgrid.css" type=TEXT/CSS
			rel=StyleSheet></LINK>
		<LINK href="<%=basePath%>js/tree/dtree/dtree.css" type=text/css
			rel=StyleSheet>
		<SCRIPT src="<%=basePath%>js/tree/dtree/dtree.js" type=text/javascript></SCRIPT>
		<SCRIPT src="<%=basePath%>js/list/dhtmlxcommon.js"
			type=text/javascript></SCRIPT>
		<SCRIPT src="<%=basePath%>js/list/dhtmlxgrid.js" type=text/javascript></SCRIPT>
		<SCRIPT src="<%=basePath%>js/list/dhtmlxgridcell.js"
			type=text/javascript></SCRIPT>
		<SCRIPT src="<%=basePath%>js/list/dhtmlxgrid_start.js"
			type=text/javascript></SCRIPT>
	</head>
	<%
		Role role = new Role();
		String act = (String) request.getAttribute("act");
		String actName = "";
		if ("add".equals(act)) {
			actName = "新增";
		}
		if ("edit".equals(act)) {
			actName = "编辑";
		}
		role = (Role) request.getAttribute("roleObj");
		if (role == null) {
			role = new Role();
		}
	%>
	
	<body style="MARGIN: 0px;" id="body">
		<TABLE height="100%" cellSpacing=0 cellPadding=0 width="100%"
			align=center border=0>
			<TBODY>
				<TR>
					<TD style="WIDTH:100%; HEIGHT: 12px" background=<%=basePath%>
						images/commom/index_r4_c9.jpg colSpan=2></TD>
				</TR>
				<TR>
					<TD align=top width=100%>
						<TABLE height="100%" cellSpacing=0 cellPadding=0 width="90%"
							border=0 align="center">
							<TBODY>
								<TR>
									<TD height=26>
										<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0
											align="center">
											<TBODY>
												<TR>
													<TD class=linelabel3 vAlign=bottom background=<%=basePath%>images/commom/00_r5_c30.jpg>
														系统管理>>角色管理
													</TD>
												</TR>
											</TBODY>
										</TABLE>
									</TD>
								</TR>
								<TR>
									<TD class=border2 width="90%" height="100%" valign="top">
										<FORM id=fm1 name=fm1 action="/chis/manager/role!insertUser.action"  method=post>
											<TABLE cellSpacing=10 width="100%">
												<TBODY>
													<tr>
														<td class=contenttab1 height="26px">
															当前操作：角色管理>>
															<span id="processview" style="color:red"><%=actName%>
															</span>
														</td>
													</tr>
													<TR>
														<TD class=contenttab1 vAlign=top>
															<TABLE cellSpacing=2 cellPadding=0 width="100%" border=0>
																<TBODY>
																	<TR>
																		<TD class=contenttab2>
																			角色名称
																		</TD>
																		<TD class=contenttab1 width="80%" colspan="3">
																			<INPUT class=input3 id=rolename name=rolename
																				value="<%=role.getRolename()%>">
																			<INPUT class=input3 id=roleid name=roleid
																				value="<%=role.getId()%>" type="hidden">
																			<INPUT class=input3 id=act name=act value="<%=act%>"
																				type="hidden">
																		</TD>
																	</TR>
																	<TR>
																		<TD class=contenttab2>
																			角色编码
																		</TD>
																		<TD class=contenttab1 width="40%">
																			<INPUT class=input2 id=rolecode name=rolecode
																				value="<%=role.getRolecode()%>">
																		</TD>
																		<TD class=contenttab2>
																			是否启用
																		</TD>
																		<TD class=contenttab1 width="40%">
																			<%
																			 if ("1".equals(role.getIsUsed())) {
																			%>
																			<input type="radio" name=isused " id="isused" checked="checked" value="1">
																			启用
																			<input type="radio" name="isused" id="isused" value="0">
																			停用
																			<%
																			  }else {
																			%>
																			<input type="radio" name=isused " id="isused" value="1">
																			启用
																			<input type="radio" name="isused" checked="checked" id="isused" value="0">
																			停用
																			<%
																			  }
																			%>
																		</TD>
																	</TR>
																	<TR>
																		<TD class=contenttab2>
																			功能分配
																		</TD>
																		<TD class=contenttab1 colspan="3">
																			<TABLE cellSpacing=10 width="100%" height="100%">
																				<TBODY>
																					<TR>
																						<TD vAlign=top>
																							<SCRIPT type=text/javascript>
						        basepath='<%=basePath%>';
						        //objName,showSonMuber,showCheckBox,checkboxType,onlySelectLeaf
                                d = new dTree('d',false,true,'checkbox',false);
						<%
						List<Menu> list=(List<Menu> )request.getAttribute("mentList");
						     if(list!=null&&list.size()>0){
						      for(Menu menu:list){
						%>
						    //id, pid, name, url, title, target, icon, iconOpen, open,checked,disabled,clickMethod
                            d.add('<%=menu.getId()%>','<%=menu.getParentid()%>','<%=menu.getName()%>','','<%=menu.getName()%>','workspaceframe0', '', '', '',<%=menu.getIsused()==2?true:false %>,'','checkboxSelProcess(this)');
                       <%
                             }
                               }
                         %>
                             document.write(d);
                             d.openAll();
                        </SCRIPT>
																						</TD>
																					</TR>
																				</TBODY>
																			</TABLE>
																		</TD>
																	</TR>
																</TBODY>
															</TABLE>
														</TD>
													</TR>
													<tr height="40">
														<td align="center">
															<table border='0' cellpadding='2' cellspacing='0'
																id="buttonprcess">
																<tr height="20">
																	<td
																		style='background-image:url(<%=basePath%>images/button/w_buttonrleft1.gif);width:6px;'></td>
																	<td
																		style='background-image:url(<%=basePath%>images/button/w_buttonmiddle1.gif);cursor: hand;'
																		onclick="fm1.submit()">
																		保存
																	</td>
																	<td
																		style='background-image:url(<%=basePath%>images/button/w_buttonright1.gif);width:6px;'></td>
																	<td>
																		&nbsp;
																	</td>
																	<td
																		style='background-image:url(<%=basePath%>images/button/w_buttonrleft1.gif);width:6px;'></td>
																	<td
																		style='background-image:url(<%=basePath%>images/button/w_buttonmiddle1.gif);cursor: hand;' onclick="fm1.reset()">
																	    取消
																	</td>
																	<td
																		style='background-image:url(<%=basePath%>images/button/w_buttonright1.gif);width:6px;'></td>
																	<td>
																		&nbsp;
																	</td>
																	<td
																		style='background-image:url(<%=basePath%>images/button/w_buttonrleft1.gif);width:6px;'></td>
																	<td
																		style='background-image:url(<%=basePath%>images/button/w_buttonmiddle1.gif);cursor: hand;'>
																		<a
																			href="/chis/manager/role!roleList.action?deptid=0">返回</a>
																	</td>
																	<td
																		style='background-image:url(<%=basePath%>images/button/w_buttonright1.gif);width:6px;'></td>
																</tr>
															</table>
														</td>
													</tr>
												</TBODY>
											</TABLE>
										</FORM>
									</TD>
								</TR>
							</TBODY>
						</TABLE>
					</TD>
				</TR>
			</TBODY>
		</TABLE>
	</body>
	<script type="text/javascript">
	  //构造xmlhttp方法
function getXMLHTTPRequest() {
	if (typeof XMLHttpRequest != "undefined") 
	{
	  return new XMLHttpRequest();
	} 	
	else if (window.ActiveXObject) 
	{
		
		var oXmlHttp = new ActiveXObject("MSXML2.XMLHttp.3.0");
		return oXmlHttp;		
	}
	else {
		alert("浏览器不支持xmlhttp，请用高版本的IE或Firefox");
		return null;		
	}
}

//调用子类
function checkboxSelProcess(obj) {
        var menuid=obj.id;
  		xmlHttp = getXMLHTTPRequest();
		xmlHttp.onreadystatechange = onReadyStateChange;
		var url = "<%=basePath%>role/function?functionid="+ menuid+"&Random="+Math.random();	
		xmlHttp.open("GET", url);
		xmlHttp.send();
}

function onReadyStateChange() {
	var ready = xmlHttp.readyState;
	if (ready == 4) {
		var xmlDoc = xmlHttp.responseXML; 
		var nodeIdSet=xmlDoc.getElementsByTagName('node');
		var currentid=nodeIdSet[0].getAttribute("value");
		var checked=document.getElementById(currentid).checked;
		if(checked){
		for(var i=1;i<nodeIdSet.length;i++){
		   var dataNoteId=nodeIdSet[i].getAttribute("value");
		     document.getElementById(dataNoteId).checked=checked;
		}
		}else{
		  for(var i=1;i<nodeIdSet.length;i++){
		    var dataNoteId=nodeIdSet[i].getAttribute("value");
		    var isChild=nodeIdSet[i].getAttribute("attr");
		   // alert(isChild);
		    if(isChild=="child"){
		     document.getElementById(dataNoteId).checked=checked;
		     }
		  }
		}
	}
	else
	 ;
}
	</script>
</html>
